/* 搜索页面样式 - 使用首页样式 */

/* CSS变量定义 */
:root {
  --primary-color: #0066ff;
  --primary-light: rgba(0, 102, 255, 0.1);
  --primary-dark: #0052cc;
  --text-primary: #333;
  --text-secondary: #666;
  --text-light: #999;
  --border-color: #f0f0f0;
  --background-light: #f6f8fb;
  --white: #ffffff;
  --transition-normal: 0.3s ease;
  --border-radius: 0.75rem;
  --border-radius-small: 0.5rem;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
}

/* 全屏搜索容器 - 使用首页背景 */
.search-page {
  width: 100%;
  min-height: 100vh;
  background: var(--background-light);
  padding: 0;
  margin: -64px 0 0 0; /* 抵消Layout组件的margin-top: 64px */
  padding-top: 64px; /* 确保内容不被顶部导航遮挡 */
  position: relative !important;
  transform: none !important;
  -webkit-transform: none !important;
  will-change: auto !important;
  perspective: none !important;
  contain: none !important;
}

/* 搜索头部区域 - 全屏背景 */
.search-hero {
  width: 100vw;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  padding: 2rem 0;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.search-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(0.5rem);
}

.search-hero-content {
  max-width: 75rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  position: relative;
  z-index: 1;
}

/* 搜索框容器 */
.search-container {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 0.75rem;
  margin: 1.5rem 0;
  border: 0.0625rem solid rgba(255, 255, 255, 0.2);
  max-width: 48rem;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.5rem;
  font-size: 1rem;
  color: var(--text-primary);
  background: transparent;
}

.search-input::placeholder {
  color: var(--text-light);
}

.search-button {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius-small);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-button:hover {
  background: var(--primary-dark);
}

/* 主要内容区域 */
.search-content {
  margin: 0 auto;
  padding: 0 1rem;
  width: 100%;
  max-width: 100rem;
  box-sizing: border-box;
}

/* 搜索结果统计和筛选区域 */
.search-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-radius: 0.5rem;
  border: 1px solid #e1e5e9;
}

.search-stats h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 600;
}

.search-stats p {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* 当前搜索关键词显示区域 */
.current-search-query {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--primary-light);
  border-radius: 0.5rem;
  border: 1px solid var(--primary-color);
  border-width: 1px;
  border-style: solid;
  border-color: rgba(0, 102, 255, 0.2);
}

.search-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.search-keyword {
  font-size: 0.875rem;
  color: var(--primary-color);
  font-weight: 600;
  background: var(--white);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(0, 102, 255, 0.2);
}

.clear-search {
  background: var(--white);
  border: 1px solid rgba(0, 102, 255, 0.2);
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 0.75rem;
  transition: all 0.2s ease;
  margin-left: auto;
}

.clear-search:hover {
  background: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
}

.search-stats-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-stats-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.search-stats-count mark {
  background: var(--primary-light);
  color: var(--primary-color);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-weight: 600;
  margin: 0 0.25rem;
}

.search-stats-clear {
  font-size: 0.75rem;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  background: var(--background-light);
}

.search-stats-clear:hover {
  color: var(--primary-color);
  background: var(--primary-light);
}

/* 筛选区域 */
.search-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--white);
  border-radius: 0.5rem;
  border: 1px solid #e1e5e9;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.filter-select {
  min-width: 8rem;
  height: 2rem;
  padding: 0 0.75rem;
  border: 1px solid #e1e5e9;
  border-radius: 0.375rem;
  background: var(--white);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8.825L1.175 4 2.05 3.125 6 7.075 9.95 3.125 10.825 4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
}

.filter-select:hover {
  border-color: var(--primary-color);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* 搜索结果网格 - 使用统一响应式布局 */
.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

/* 超大屏幕最多显示6列 */
@media (min-width: 1600px) {
  .search-results {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* 大屏幕显示4-5列 */
@media (min-width: 1200px) and (max-width: 1599px) {
  .search-results {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 中等屏幕显示3列 */
@media (min-width: 901px) and (max-width: 1199px) {
  .search-results {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 小屏幕显示2列 */
@media (min-width: 769px) and (max-width: 900px) {
  .search-results {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* 搜索结果卡片 */
.search-result-card {
  background: var(--white);
  border-radius: 0.5rem;
  padding: 0.875rem;
  border: 0.0625rem solid #e1e5e9;
  transition: border-color 0.3s ease, transform 0.3s ease;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  /* 统一卡片大小 - 固定高度和宽度 */
  height: 120px;
  overflow: hidden;
  /* 确保卡片不会被内容撑大 */
  box-sizing: border-box;
}

.search-result-card:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* 左侧图标区域 - 参考GitHub样式 */
.search-result-icon {
  width: 2rem;
  height: 2rem;
  background: transparent;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.search-result-icon img {
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  object-fit: cover;
}

.search-result-icon-fallback {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--background-light);
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 右侧内容区域 - 参考GitHub卡片布局 */
.search-result-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  /* 确保内容在固定高度内合理分布 */
  justify-content: space-between;
  height: 100%;
}

.search-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0;
  flex-shrink: 0;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25rem 0;
  line-height: 1.3;
  text-decoration: none;
  color: var(--text-primary);
}

.search-result-title:hover {
  text-decoration: underline;
}

.search-result-badges {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.result-badge {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--white);
}

.result-badge.hot {
  background: #ef4444;
}

.result-badge.new {
  background: var(--success-color);
}

.result-badge.featured {
  background: var(--warning-color);
}

.search-result-description {
  font-size: 0.800rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0 0 0.000rem 0;
  /* 确保描述文本在固定高度内显示 - 两行省略号 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  max-height: 2.8em; /* 约两行文本的高度 */
  /* 兼容性处理 */
  word-wrap: break-word;
  word-break: break-word;
}

/* 搜索结果标签 */
.search-result-tags {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  /* 限制标签显示数量，避免溢出 */
  max-height: 1.5rem;
  overflow: hidden;
}

.result-tag {
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  border: 0.0625rem solid color-mix(in srgb, var(--border-color) 40%, transparent 60%); /* 更淡的边框 */
  background: color-mix(in srgb, var(--background-light) 60%, transparent 40%); /* 更淡的背景 */
  color: var(--text-quaternary, #9ca3af); /* 更淡的文字颜色 */
  opacity: 0.8; /* 增加整体透明度 */
  transition: all 0.2s ease;
}

.result-tag:hover {
  background: color-mix(in srgb, var(--primary-light) 60%, transparent 40%); /* 更淡的hover背景 */
  color: color-mix(in srgb, var(--primary-color) 80%, transparent 20%); /* 更淡的hover文字 */
  opacity: 1; /* hover时恢复不透明 */
}

/* 搜索结果信息栏 - 底部元数据区域，模仿首页样式 */
.search-result-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-light);
  /* 固定在底部 */
  flex-shrink: 0;
  margin-top: auto;
}

.result-rating {
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--warning-color);
  font-weight: 500;
}

.result-pricing {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--white);
}

.result-pricing.free {
  background: var(--success-color);
}

.result-pricing.freemium {
  background: var(--info-color);
}

.result-pricing.paid {
  background: var(--warning-color);
}

.result-source {
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.search-result-category {
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.025rem;
}

/* 加载状态 */
.search-loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.loading {
  width: 2rem;
  height: 2rem;
  border: 0.125rem solid var(--border-color);
  border-top: 0.125rem solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 空状态 */
.search-empty {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.search-empty-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.search-empty-description {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* 搜索建议 */
.search-suggestions {
  margin-top: 1.5rem;
}

.search-suggestions p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.suggestion-tag {
  background: var(--primary-light);
  color: var(--primary-color);
  border: 0.0625rem solid var(--primary-color);
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-small);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-normal);
}

.suggestion-tag:hover {
  background: var(--primary-color);
  color: var(--white);
}

/* 移动端适配 */
@media (max-width: 768px) {
  .suggestion-tag {
    padding: 0.25rem 0.75rem; /* 减小内边距 */
    font-size: 0.75rem; /* 减小字体 */
    border-radius: 1rem; /* 小一点的圆角 */
  }
  
  .search-suggestions p {
    font-size: 0.75rem;
  }
}

/* 欢迎页面 */
.search-welcome {
  text-align: center;
  padding: 3rem;
  background: var(--white);
  border-radius: var(--border-radius);
  border: 0.0625rem solid var(--border-color);
}

.search-welcome-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.search-welcome-description {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.search-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1.5rem;
  max-width: 32rem;
  margin: 0 auto;
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--background-light);
  border-radius: var(--border-radius-small);
}

.feature-icon {
  font-size: 2rem;
}

.feature-item span:last-child {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* 响应式设计 */
@media (max-width: 64rem) {
  html {
    font-size: 14px;
  }
  
  .search-content {
    max-width: 100%;
    padding: 0 1rem;
  }
  
  .search-stats {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .search-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filter-group {
    width: 100%;
    justify-content: space-between;
  }

  .filter-select {
    flex: 1;
    max-width: 100%;
  }

  .search-results {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .search-result-card {
    padding: 0.75rem;
  }
}

@media (max-width: 48rem) {
  html {
    font-size: 12px;
  }

  .search-content {
    max-width: 100%;
    padding: 0 1rem;
  }

  .search-stats {
    padding: 0.75rem;
  }

  /* 移动端搜索关键词显示优化 */
  .current-search-query {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.25rem;
  }

  .search-keyword {
    font-size: 0.8125rem;
    padding: 0.1875rem 0.375rem;
  }

  .clear-search {
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.6875rem;
  }

  .search-filters {
    padding: 0.75rem;
  }

  .filter-label {
    font-size: 0.8125rem;
  }

  .filter-select {
    font-size: 0.8125rem;
  }

  .search-results {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .search-result-card {
    padding: 0.75rem;
  }

  .search-result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .search-result-badges {
    align-self: flex-end;
  }

  .search-result-info {
    gap: 0.5rem;
  }

  .search-features {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .search-welcome-title {
    font-size: 1.5rem;
  }

  .search-welcome-description {
    font-size: 1rem;
  }
}

/* 小屏幕设备优化 (iPhone SE等) */
@media (max-width: 375px) {
  .search-result-card {
    padding: 0.625rem;
    min-height: 110px;
  }

  .search-result-title {
    font-size: 0.8125rem;
  }

  .search-result-description {
    font-size: 0.6875rem;
  }

  .search-result-icon,
  .search-result-icon img,
  .search-result-icon-fallback {
    width: 1.75rem;
    height: 1.75rem;
  }

  .search-result-icon-fallback {
    font-size: 0.75rem;
  }
}

/* 横屏优化 */
@media (max-width: 750px) and (max-height: 500px) and (orientation: landscape) {
  .search-result-card {
    min-height: 100px;
  }
} 